package algotithm.leetcode.math.test326;

/**
 * @author zhouyanxiang
 * @Date 2021-01-2021/1/27-11:38
 */
class Solution {

    public static void main(String[] args) {
        Solution solution = new Solution();
        int n = 81;
        boolean powerOfThree = solution.isPowerOfThree(n);
        System.out.println(powerOfThree);
    }

    public boolean isPowerOfThree(int n) {
        if (n == 0) {
            return false;
        }
        while (n != 1) {
            if (n % 3 == 0) {
                n = n / 3;
            } else {
                return false;
            }
        }
        return true;
    }
}
